package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.service.GoodsService;
import com.jx.servicrimpl.GoodsServiceImpl;

import net.sf.json.JSONObject;
/**
 * 删除配送信息表
 * @author 鄢泽然
 *
 */
public class DeleteGoodsController extends HttpServlet{
	GoodsService gs = new GoodsServiceImpl();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		  System.out.println("deleteGoods");
	  req.setCharacterEncoding("utf8");
	  resp.setCharacterEncoding("utf8");
	  String[] id = req.getParameterValues("oid[]");

	 
	  int flag = 0;
	  for (int i = 0; i < id.length; i++) {
		flag = gs.deleteGoods(Integer.parseInt(id[i]));
	  }
	  	JSONObject j = new JSONObject();
	  	j.put("s", flag);
		PrintWriter pw = resp.getWriter();
		pw.write(j.toString());
		pw.flush();
		pw.close();
	}

}
